﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace DataAccess.Operate
{
    public class DA_Report_ChangeOperater_Inherit:SqlInteractionBase
    {

        public DataSet Search(string Report_ChangeOperater_ReportNO, string Report_ChangeOperater_ExchangeDate)
        {

            
            string sSql = "select * from t_Report_ChangeOperater where 1=1 ";
            if (Report_ChangeOperater_ReportNO != "") sSql += "and Report_ChangeOperater_ReportNO like '%" + Report_ChangeOperater_ReportNO + "%'";
            if (Report_ChangeOperater_ExchangeDate != "") sSql += " and Report_ChangeOperater_ExchangeDate='" + Report_ChangeOperater_ExchangeDate + "'";
         

            SqlCommand cmdToExecute = new SqlCommand();
            SqlDataAdapter adapter = new SqlDataAdapter(cmdToExecute);
            DataSet ds = new DataSet();

            cmdToExecute.CommandText = sSql;
            cmdToExecute.CommandType = CommandType.Text;

            try
            {
                cmdToExecute.Connection = _mainConnection;
                if (_mainConnectionIsCreatedLocal)
                {
                    _mainConnection.Open();
                }
                else
                {
                    if (_mainConnectionProvider.IsTransactionPending)
                    {
                        cmdToExecute.Transaction = _mainConnectionProvider.CurrentTransaction;
                    }
                }

                adapter.Fill(ds);

            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message.ToString());
            }
            finally
            {
                if (_mainConnectionIsCreatedLocal)
                {
                    _mainConnection.Close();
                }

                cmdToExecute.Dispose();

                adapter.Dispose();
            }

            return ds;
        }

        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="id">主键ID</param>
        /// <param name="audit">审核步骤ID</param>
        /// <returns></returns>
        public bool AuditByID(string id, string audit)
        {
            string sSql = "update t_Report_ChangeOperater set Report_Plan_Audit=" + audit + " where Report_ChangeOperater_ID='" + id + "'";
            return RunNoneSQL(sSql);
        }
    }
}
